home *** CD-ROM | disk | FTP | other *** search
- 'Supply the name of the outline control you want to sort when calling
- 'this routine. There must be a list box on your form named 'Sorter'
- 'and it must have its Sort property set to 'True'.
- '
- 'This routine will sort an outline control that has only one
- 'sub-level (That was all I needed.) but it can be modified to
- 'sort as many levels as are needed. If you do modify it to sort
- 'unlimited levels, please contribute the result to the MS BASIC
- 'forum
- '
- Sub SortOutline (outline As Control)
-
- Dim X%, i%, Sep$
-
- Sorter.Clear ' Clear the sorter list box
- Sep$ = outline.PathSeparator ' Save the existing path separator
- outline.PathSeparator = Chr(31) ' Set path separator to something below space (ASCII 32)
- For X% = 0 To outline.ListCount - 1
- Sorter.AddItem outline.FullPath(X%) ' Add full path of items to list box
- Next X%
- outline.Clear ' clear outline control so sorted items can be added
- For X% = 0 To Sorter.ListCount - 1
- i% = InStr(Sorter.List(X%), Chr(31))
- ' If there is a seperator then add the second path item to the outline control
- If i% Then
- outline.AddItem Mid$(Sorter.List(X%), i% + 1)
- outline.PictureType(outline.ListCount - 1) = 2 ' make the picture a leaf
- Else
- ' If there is no seperator then this isa top level item
- outline.ListIndex = -1 ' Set listindex so AddItem will add a top level item
- outline.AddItem Sorter.List(X%) ' add the top level item
- outline.PictureType(outline.ListCount - 1) = 0 'set picture type to closed top level (PictureClosed)
- ' Set ListIndex to top level control so each new item added will be a sub item to it.
- outline.ListIndex = outline.ListCount - 1
- End If
- Next
- outline.PathSeparator = Sep$ ' Restore previous path separator
-
- End Sub
-